import { COLUMN_WIDTH, createCommonPage } from '@/utils/service.js'
import { dateFormat } from '@/utils/date'

export const createForm = () => ({
  startTime: '',
  endTime: '',
  timeType: '本周',
  ...createCommonPage(),
})

export const createColumns_spread = (vm) => [
  {
    title: '序号',
    key: 'id',
    align: 'center',
    width: 80,
    render(h, params) {
      return <div>{(vm.formData.pageNo - 1) * vm.formData.pageSize + params.index + 1}</div>
    },
  },
  { title: '单位名称', key: 'organ', align: 'center' },
  {
    title: '发布时间',
    align: 'center',
    width: COLUMN_WIDTH + 50,
    render(h, params) {
      return <div>{dateFormat(params.row.spreadTime || '', 'YYYY.MM.DD')}</div>
    },
  },
  { title: '发布位置', key: 'location', align: 'center' },
  { title: '上稿时长', key: 'keepTime', align: 'center' },
  { title: '点击量', key: 'clickCount', align: 'center' },
  { title: '点赞量', key: 'likeCnt', align: 'center' },
  { title: '转发量', key: 'forwardNum', align: 'center' },
  { title: '评论量', key: 'replyCnt', align: 'center' },
  { title: '收藏量', key: 'collectNum', align: 'center' },
]

export const createColumns_hotComment = (vm) => [
  {
    title: '序号',
    key: 'id',
    align: 'center',
    width: 80,
    render(h, params) {
      return <div>{(vm.formData.pageNo - 1) * vm.formData.pageSize + params.index + 1}</div>
    },
  },
  { title: '评论内容', width: COLUMN_WIDTH + 400, key: 'comment', align: 'center' },
  { title: '发布账号', key: 'username', align: 'center' },
  { title: '所属媒体', key: 'sitename', align: 'center' },
  {
    title: '发布时间',
    align: 'center',
    width: COLUMN_WIDTH + 50,
    render(h, params) {
      return <div>{dateFormat(params.row.urlTime || '', 'YYYY.MM.DD')}</div>
    },
  },
  { title: '点赞量', key: 'likeCnt', align: 'center' },
]
